Generating Applications with ApplicationSet

Automating the generation of Argo CD Applications with the ApplicationSet Controller

The ApplicationSet controller is a sub-project of Argo CD which adds Application automation, and seeks to improve multi-cluster support and cluster multitenant support within Argo CD. Argo CD Applications may be templated from multiple different sources, including from Git or Argo CD’s own defined cluster list.

The set of tools provided by the ApplicationSet controller may also be used to allow developers (without access to the Argo CD namespace) to independently create Applications without cluster-administrator intervention.

The ApplicationSet controller is installed alongside Argo CD (within the same namespace), and the controller automatically generates Argo CD Applications based on the contents of a new ApplicationSet Custom Resource (CR).

Here is an example of an ApplicationSet resource that can be used to target an Argo CD Application to multiple clusters:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: ApplicationSet
  3. metadata:
  4. name: guestbook
  5. spec:
  6. generators:
  7. - list:
  8. items:
  9. - cluster: engineering-dev
  10. url: https://1.2.3.4
  11. - cluster: engineering-prod
  12. url: https://2.4.6.8
  13. - cluster: finance-preprod
  14. url: https://9.8.7.6
  15. template:
  16. metadata:
  17. name: '{{cluster}}-guestbook'
  18. spec:
  19. project: default
  20. source:
  21. repoURL: https://github.com/argoproj-labs/applicationset.git
  22. targetRevision: HEAD
  23. path: examples/list-generator/guestbook/{{cluster}}
  24. destination:
  25. server: '{{url}}'
  26. namespace: guestbook

The List generator passes the url and cluster fields into the template as {{param}}-style parameters, which are then rendered into three corresponding Argo CD Applications (one for each defined cluster). Targeting new clusters (or removing existing clusters) is simply a matter of altering the ApplicationSet resource, and the corresponding Argo CD Applications will be automatically created.

Likewise, changes made to the ApplicationSet template fields will automatically be applied to every generated Application. Managing a set of multiple Argo CD Applications is thus as easy as managing a single ApplicationSet resource.

Within ApplicationSet there exist other more powerful generators in addition to the List generator, including the Cluster generator (which automatically uses Argo CD-defined clusters to template Applications), and the Git generator (which uses the files/directories of a Git repository to template applications).

To learn more about the ApplicationSet controller, check out ApplicationSet documentation and Getting Started to install the ApplicationSet controller alongside Argo CD.